<template>
  <view class="map">
    <map :show-location="true" id="map1756089772" style="width: 100%; height: 80vh;" :latitude="latitude"
      :longitude="longitude" :markers="markers" covers="{{covers}}"></map>
  </view>

</template>
<script>
  import { useUserStore } from '@/store'
  import { agreementDetail } from '@/api/index.js'
  export default {
    props: {
      orderForm: {
        type: Object,
        default: () => { }
      }
    },
    data() {
      return {
        latitude: 32.016627,
        longitude: 120.269009,
        markers: [],
        covers: [],
        routeQuery: {}
      }
    },
    onReady(e) {
      this.mapCtx = wx.createMapContext('map1756089772')
       this.mapCtx.moveToLocation()
    },
    onLoad(options) {
      if (options) this.routeQuery = options

    },
    mounted() {
      const user = useUserStore()
      let longitude = this.orderForm.delivery_address_lng
      let latitude = this.orderForm.delivery_address_lat
      this.markers = [
        {
          id: new Date().getTime(),
          latitude: latitude,
          longitude: longitude,
          width: 50,
          height: 50,
          iconPath: this.orderForm.avatar
        }
      ]
      this.longitude = longitude
      this.latitude = latitude
    },
    methods: {
      leftClick() {
        if (this.routeQuery.type == 1 || this.routeQuery.type == 2) {
          uni.navigateBack({ url: '/pages-worker/checkout/fetch?type=' + this.routeQuery.type })
        }
        if (this.routeQuery.type == 3) {
          uni.navigateBack({ url: '/pages-worker/checkout/buy?type=' + this.routeQuery.type })
        }
        if (this.routeQuery.type == 4) {
          uni.navigateBack({ url: '/pages-worker/pet?type=' + this.routeQuery.type })
        }
      }
    }
  }
</script>